/*
 * Jenny Ruppen 09-730-391
 * Sebastien Goldberg 08-914-855
 * Henry Raymond 08-928-061
 * Stefan Mussato 09-752-270
 */
 
package ch.uzh.ifi.sopra.gruppe9.game;


/**
 * Creates a mouseOverable and clickable area in the GUI without displaying anything.
 */
public class GuiInteractiveArea implements IMouseOverable, IClickable {
	
	
	/**
	 * Offset of the coordinate system of this area.
	 */
	private GUI.Offset offset;
	
	
	/**
	 * Position of the area in the x axis. (Assuming the window has a width of 1024 pixel.)
	 */
	private int positionX;
	
	
	/**
	 * Position of the area in the y axis. (Assuming the window has a height of 768 pixel.)
	 */
	private int positionY;
	
	
	/**
	 * Width of the area. (Assuming the window has a width of 1024 pixel.)
	 */
	private int width;
	
	
	/**
	 * Height of the area. (Assuming the window has a height of 768 pixel.)
	 */
	private int height;
	
	
	/**
	 * Callback function which is called when are is clicked.
	 */
	private ICallback action;
	
	
	/**
	 * Callback function called when mouse moves over area.
	 */
	private ICallback mouseOverAction;
	
	
	/**
	 * Callback function called when mouse moves out of the area.
	 */
	private ICallback mouseOutAction;

	
	
	/**
	 * Constructor
	 */
	public GuiInteractiveArea(GUI.Offset offset, int positionX, int positionY, int width, int height) {
		this.offset = offset;
		this.positionX = positionX;
		this.positionY = positionY;
		this.width = width;
		this.height = height;
	}
	
	
	/**
	 * Set callback function which is called when area is clicked.
	 */
	public void setAction(ICallback action) {
		this.action = action;
	}
	
	
	/**
	 * Set callback function which is called when mouse moves over area.
	 */
	public void setMouseOverAction(ICallback action) {
		this.mouseOverAction = action;
	}
	
	
	/**
	 * Set callback function which is called when mouse moves out of the area.
	 */
	public void setMouseOutAction(ICallback action) {
		this.mouseOverAction = action;
	}
	
	
	@Override
	public GUI.Offset getOffset() {
		return offset;
	}


	@Override
	public int getPositionX() {
		return positionX;
	}


	@Override
	public int getPositionY() {
		return positionY;
	}


	@Override
	public int getWidth() {
		return width;
	}


	@Override
	public int getHeight() {
		return height;
	}


	@Override
	public void onMouseOver() {
		mouseOverAction.run();
	}


	@Override
	public void onMouseOut() {
		mouseOutAction.run();
	}
	
	
	@Override
	public void onMouseDown(int mouseX, int mouseY) {
	}


	@Override
	public void onMouseUp(int mouseX, int mouseY) {
		action.run();	
	}
}
